(function (w) {
   let res={
      get: function (option) {
         let xhr = new XMLHttpRequest();
         if (option.data) {
            option.url += '?';
            option.url += option.data;
         }
         xhr.open('get', option.url)
         xhr.onload = function () {
            option.success(xhr.response)
         }
         xhr.send();
      },
      post: function (option) {
         let xhr = new XMLHttpRequest();
         xhr.open('post', option.url)
         xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded')
         xhr.onload = function () {
            option.success(xhr.response)
         }
         xhr.send(option.data);
      },
      ajax:function (option) {
         if (option.type == undefined || option.type == 'get' || option.type == 'GET') {
            this.get(option);//调用get方法
         }
         if (option.type == 'post' || option.type == 'POST') {
            this.post(option);//调用post方法
         }
      },
   }
   w.my = res;
})(window)